from collections import namedtuple


# namedtuple
# UserType = namedtuple("UserType", ["name", "email"])

# user_type = UserType("admin", "admin@163.com")

# user_type2 = ("admin", "admin@163.com")

# print(user_type[0],user_type.name)
# print(user_type2)
# print(user_type2[0], user_type2[1])

# deque

from collections import deque
# q = deque(["a", "b", "c"])
# print("origin >>> ", q)

# q.append("d")
# print("append >>>", q) # 在列表右则增加d

# q.appendleft("y")
# print("append left >>>", q) # 在队表左则增加y

# dict defaultdict 全用get方法，没有键时返回None,使用索引访问没有键时报错
d = {"name":"jim", "age":10}
# print("d >>>", d)
# name = d.get("name")
# print("d.get name >>>", name)
# name2 = d.get("name2")
# print("d.get name2 >>>", name2)
# name2 = d.get("name2","N/A")
# print("d.get name2 with default >>>", name2)

# print("d index >>>", d["name"], d["age"])
# try:
# 	print("d index name2 >>> ", d["name2"])
# except Exception as ex:
# 	print("d index name2 ex:", ex)

# from collections import defaultdict
# d2 = defaultdict(lambda: 'N/A')
# print("d2.name", d2["name"])

d["test"] = "test"
print(d)

